package day2;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * ClassName：TestArrayList
 *
 * @Author：小鱼
 * @Create：2025-08-12 9:44
 */
public class TestArrayList {
    public static void main(String[] args) {
        final int num = 100000;
        List<String> list1 = new LinkedList<>();
        //计时
        Long start = System.currentTimeMillis();
        for (int i = 0; i < num; i++) {
            list1.add(0,"hello"+i);
        }
        Long end = System.currentTimeMillis();
        System.out.println("插入"+num+"条数据，需要"+(end-start)+"毫秒");




        //计时
        Long start1 = System.currentTimeMillis();
        for (int i = 0; i < num; i++) {
            list1.get(i);
        }
        Long end1 = System.currentTimeMillis();
        System.out.println("查询"+num+"条数据，需要"+(end1-start1)+"毫秒");
    }
}
